# -*- coding: utf-8 -*-

import  wx

from  stc.stc_base import STCBase
import  depythonize

class STCInput(STCBase):
  def __init__(self, parent, ID, faces, stc_output, stc_debug,
         pos=wx.DefaultPosition, size=wx.DefaultSize,
         style=0):
    STCBase.__init__(self, parent, ID, faces, pos, size, style)
    self.Bind(wx.EVT_KEY_UP, self.OnSTCChange)
    self.stc_output = stc_output
    self.stc_debug = stc_debug

  def OnSTCChange(self,event):
    text = self.GetText().encode('UTF-8')

    text_trans = depythonize.translate_py(text)
    text_trans = text_trans.decode('UTF-8', 'replace')
    self.stc_output.SetText(text_trans)

    text_tokens = depythonize.print_tokens_py(text)
    text_tokens = text_tokens.decode('UTF-8', 'replace')
    self.stc_debug.SetText(text_tokens)



